package com.learn.jvm.basic;

import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;

public class Basic04 {

    public static void main(String[] args) {

        byte[] array = new byte[20 * 1024 * 1024]; // 10M  分配eden区或者old区
        for (MemoryPoolMXBean memoryPoolMXBean : ManagementFactory.getMemoryPoolMXBeans()) {
            System.out.println(memoryPoolMXBean.getName() +
                    " 已经使用：" + memoryPoolMXBean.getUsage().getUsed() / 1024 / 1024 + "MB" +
                    " 总大小：" + memoryPoolMXBean.getUsage().getCommitted() / 1024 / 1024 + "MB");
        }
        System.out.println("Done.");

    }
}
